export default {
  data () {
    return {
      codeParent: null,
      codeContentHeight: 0,
      isShow: false,
    }
  },
  computed: {
    showCodeDesc() {
      return typeof this.codeDesc === 'string' && this.codeDesc.trim().length > 0
    }
  },
  methods: {
    //根据子元素的高度 设置代码区域父元素的高度
    showCode () {
      this.isShow = !this.isShow
      this.$nextTick(() => {
        if (this.isShow) {
          this.codeParent.style.height = +this.codeContentHeight + 25 + 'px'
        } else {
          this.codeParent.style.height = 0
        }
      })
    },
    //得到所有代码区域的高度
    getCodesHeight () {
      this.codeContentHeight = this.$refs.codeContentHeight.getBoundingClientRect().height
      this.codeParent = this.$refs.codeContent
    },
  },
  mounted () {
    this.$nextTick(() => {
      this.getCodesHeight()
    })
  },
}

